/*******************************************************************************
 *	                           bsp cpu.c
 *******************************************************************************/
#include "bsp.h"
#include "mytype.h"
#include "str_ext.h"

/*******************************************************************************
 * @brief  配置值
 *******************************************************************************/
#define TIMX TIM1

/*******************************************************************************
 * @brief  检测并配置.
 *******************************************************************************/
void pwm_init(void)
{

	TIMX->CCR1 = TIM_CR1_CKD_1 | // tdts = 4clk
				 TIM_CR1_ARPE |	 // 影子寄存器
				 TIM_CR1_CMS |	 // 中心对称PWM,上下比较均产生中断
				 TIM_CR1_URS;	 // 仅溢出产生更新中断

	TIMX->CCR2 = 0;
	TIMX->CCR3 = 0;
	TIMX->CCR4 = 0;

	TIMX->SMCR = 0;

	TIMX->CCMR1 = 0x6868;
	TIMX->CCMR2 = 0x6868;

	TIMX->CCER = TIM_CCER_CC1E | TIM_CCER_CC1NE | // 通道1
				 TIM_CCER_CC2E | TIM_CCER_CC2NE | // 通道2
				 TIM_CCER_CC3E | TIM_CCER_CC3NE;  // 通道3

	TIMX->DIER = 0;
	TIMX->ARR = 10000;
	TIMX->PSC = 0;

	TIMX->CCR1 = 2000;
	TIMX->CCR2 = 2000;
	TIMX->CCR3 = 2000;
	TIMX->CCR4 = 2000;

	
}
